#include<iostream>
#include<string> 
#include<windows.h>
#include<cstring>
#include<fstream>
#include<cmath>
#define ver "Commander 1.1"
using namespace std;
const char* ok="asudhjkwiusjhnjskiosuxjska#skmxisikjnxksjnxaxkjnksozsxkpa[splxkjnml;sdlkxl;a]as[plckm,ijkjmnhg";
ifstream passkey("passkey.dat"); 
int main(){
	string passk;
	passkey>>passk;
	if(passk!="passkeyreaded")
	{
		system("title NOT Registered");
		cout<<"Your exe is not registered, go to www.eu11992099.icoc.me to get the passkey.";
		cout<<endl<<"Input it: (\"none\" for none)";
		string pass;
		cin>>pass;
		if(pass=="none"){
		
			cout<<"None? Get it!";getchar();return 0;}
		else if(pass=="asudhjkwiusjhnjskiosuxjska#skmxisikjnxksjnxaxkjnksozsxkpa[splxkjnml;sdlkxl;a]as[plckm,ijkjmnhg"){
			cout<<"Registered! You can used it!\n";
			passkey.close(); 
			ofstream yes("passkey.dat");
			yes<<"passkeyreaded";goto YES;
			yes.close();
			system("cls");
		}else{
		
			cout<<"Wrong passkey, GET it!";
			getchar();
		return 0;}
	}
	YES:system("title Commander 1.01");
	cout<<"Commander 1.1 Alpha"<<endl;
	cout<<"Input command code \"Copyright\" to read the license.\r\n";
	string command;
	while(true){
		cout<<"Commander Shell: ";
		cin>>command;
		for(int i=0;i<command.length();i++){
		if(command[i]>='A'&&command[i]<='Z'){
			command[i]+=('a'-'A');
		}
	}
		//cout<<command;
		if(command=="delay"){
			int delaytime;
			cin>>delaytime;
			Sleep(delaytime);
		}
		else if(command=="new"){
			string mode;
			//cin>>mode;
				system("cls");
			
		}
		else if(command=="exit"){
			return 0;
		}
		
		else if(command=="web"){
			string site;
			cin>>site;
			system("cd /D C:\\");
			if(site=="~"){
				system("cd /d C:\\Program Files\\Internet Explorer");
				system("iexplore.exe www.baidu.com");
			}else if(site=="-"){
				system("cd /d C:\\Program Files\\Internet Explorer");
				system("iexplore.exe www.sogou.com");
			}else if(site=="index"){
				system("cd /d C:\\Program Files\\Internet Explorer");
				system("iexplore eu1199099.icoc.me");
			}else if(site=="bbs"){
				system("cd /d C:\\Program Files\\Internet Explorer");
				system("iexplore tongnianbbs.666forum.com");
			}else{
				system("cd /d C:\\Program Files\\Internet Explorer");
				string web="iexplore";web.append("site");
				const char *webs=web.data();
				system(webs);
			}
		}
		else if(command=="system"){
			string aaa;
			getchar();
			getline(cin,aaa,'\n');
			const char *code=aaa.data();
			//cout<<code;
			system(code);
		}
		else if(command=="copyright"){
			cout<<"Commander.exe"<<endl;
			cout<<"Copyright(c)2017-2019 Perry Inc.\n";
		}
		else if(command=="msgbox"){
			string text,title;
			int mode;
			cin>>text>>title>>mode;
			const char *Text=text.data();
			const char *Title=title.data();
			int returnvalue=MessageBox('\0',Text,Title,mode);
			cout<<"Buttonvalue="<<returnvalue<<endl;
		}
		else if(command=="help"){
			string code;
			getline(cin,code);
			cout<<"Now we haven't a help file.\n";
		}else if(command=="uninstall"){
			
			
			int ok=MessageBox(NULL,"Do you want to uninstall Commander 1.0?","Uninstall",MB_ICONQUESTION|MB_OKCANCEL);
			if(ok==1){
				system("del /S /Q commander.exe");
				MessageBox(NULL,"Finish","Finish",MB_OK);
				system("exit");
			}
		} 
		else if(command=="ver"){
			cout<<"Commander 1.1,\n  By Perry Inc.\n";
		}
		else if(command=="calc"){
			char c;
			int a,b;
			cin>>a>>c>>b;
			switch(c){
				case '+': {
					cout<<a+b<<endl;
					break;
				}
				case '-':{
					cout<<a-b<<endl;
					break;
				}
				case '*':{
					cout<<a*b<<endl;
					break;
				}
				case '/':{
					if(b==0)
						cout<<"Divided by 0!\n";
					else
						cout<<double(a)/b<<endl;
					break;
				}
				case '\\':{
					if(b==0)
						cout<<"Divided by 0!\n";
					else
						cout<<a/b<<endl;
					break;
				}
				case '^':{
					cout<<pow(a,b)<<endl;
					break;
				}
				case '%':{
					cout<<a%b<<endl;
					break;
				}
				default:{
					cout<<"Invalid operator!\n";
					break;
				}
			}
		}
		//else if(command=="")
		else{
			cout<<"ERROR! Please check the code!\n";
		}
	}
	//This is function 'main', put the main code here.
}

